import axiosInstance from "@/services/http";
import type { Result, ValidCode, AccoutLogin, EmailValid,PhoneLogin } from "@/types";


export async function getCaptchaCode(): Promise<Result<ValidCode>> {
    return await axiosInstance.get("/common/getCaptchaCode");
};

export async function validCode(params: ValidCode): Promise<Result<string>> {
    return await axiosInstance.get("/common/validCode", { params });
};

export async function phoneCode(phone: string): Promise<Result<string>> {
    return await axiosInstance.get("/common/getPhoneCode", { params: { phone } });
};

export async function accountLogin(params: AccoutLogin): Promise<Result<string>> {
    return await axiosInstance.post("/merchant/accountLogin", params);
};

export async function phoneLogin(params: PhoneLogin): Promise<Result<string>> {
    return await axiosInstance.post("/merchant/phoneLogin", params);
};

export async function resetPasssword(params: EmailValid): Promise<Result<string>> {
    return await axiosInstance.put("/merchant/resetPasssword", params);
};

export async function register(params: EmailValid): Promise<Result<string>> {
    return await axiosInstance.post("/merchant/register", params);
};

export async function merchantLogout(): Promise<Result<string>> {
    return await axiosInstance.get("/merchant/logout");
};
